var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var r in e) e.hasOwnProperty(r) && (t[r] = e[r]);
    })(t, e);
}, function(t, e) {
    function r() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (r.prototype = e.prototype, 
    new r());
}), a = this && this.__decorate || function(t, e, r, o) {
    var n, i = arguments.length, s = i < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, r) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(t, e, r, o); else for (var c = t.length - 1; 0 <= c; c--) (n = t[c]) && (s = (i < 3 ? n(s) : 3 < i ? n(e, r, s) : n(e, r)) || s);
    return 3 < i && s && Object.defineProperty(e, r, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LoadManager"), s = cc._decorator, c = s.ccclass, l = s.property, d = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.sprite = null, t.path = null, t;
    }
    return i(t, e), t.prototype.start = function() {}, t.prototype.init = function(n) {
        var i = this;
        return new Promise(function(e, o) {
            i.sprite.node.setPosition(n.pos), i.sprite.node.setParent(n.root), i.path != n.url && (i.path = n.url, 
            r.default.getInstance().loadRes({
                url: n.url,
                type: cc.SpriteFrame
            }).then(function(t) {
                try {
                    i.path == n.url ? (i.sprite.spriteFrame = t, e(i.sprite)) : o();
                } catch (t) {
                    o();
                }
            }).catch(function() {
                o();
            }));
        });
    }, t.prototype.reset = function() {
        this.sprite && (this.sprite.spriteFrame = null, this.sprite.node && (this.sprite.unscheduleAllCallbacks(), 
        cc.Tween.stopAllByTarget(this.sprite.node), this.sprite.node.removeFromParent(), 
        this.sprite.node.setPosition(cc.Vec2.ZERO), this.sprite.node.setScale(1), this.sprite.node.setAnchorPoint(.5, .5), 
        this.sprite.node.color = cc.Color.WHITE, this.sprite.node.angle = 0, this.sprite.node.opacity = 255, 
        this.sprite.node.zIndex = 0)), this.path = null;
    }, a([ l(cc.Sprite) ], t.prototype, "sprite", void 0), a([ c ], t);
}(cc.Component);

n.default = d;